﻿//
// *************************************************************************************
// WP-Framework
// 
// Developed by
// Lukas Kretschmar (lkretschmar.dev@bluewin.ch)
//
// Switzerland, Copyright (c) 2013 lkretschmar
// This content is released under the MIT License (http://opensource.org/licenses/MIT).
//     
// *************************************************************************************
//
//


using KretschIT.WP_Fx.Core.Validation;
using System;

namespace KretschIT.WP_Fx.EasyMoq.Adapters
{
    internal abstract class BaseMockAdapter<TMock, TResult> where TMock : IValueConvertable
    {
        public BaseMockAdapter(TMock mock)
        {
            It.IsNotNull(() => mock);

            this.Mock = mock;
            this.Mock.SetValueConverter(this.GetDefaultValue);
        }

        protected TMock Mock { get; private set; }

        #region Convert

        private object GetDefaultValue(object value)
        {
            var defaultValue = default(TResult);
            if (value != null && !value.Equals(defaultValue))
            {
                return value;
            }
            return defaultValue;
        }

        #endregion
    }
}
